{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: roboflow in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (1.0.9)\n",
      "Requirement already satisfied: python-dateutil in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (2.8.2)\n",
      "Requirement already satisfied: chardet==4.0.0 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (4.0.0)\n",
      "Requirement already satisfied: numpy>=1.18.5 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.24.2)\n",
      "Requirement already satisfied: requests-toolbelt in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.0.0)\n",
      "Requirement already satisfied: PyYAML>=5.3.1 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (6.0)\n",
      "Requirement already satisfied: opencv-python>=4.1.2 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (4.7.0.72)\n",
      "Requirement already satisfied: pyparsing==2.4.7 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (2.4.7)\n",
      "Requirement already satisfied: requests in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (2.28.2)\n",
      "Requirement already satisfied: Pillow>=7.1.2 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (9.4.0)\n",
      "Requirement already satisfied: six in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.15.0)\n",
      "Requirement already satisfied: idna==2.10 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (2.10)\n",
      "Requirement already satisfied: cycler==0.10.0 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (0.10.0)\n",
      "Requirement already satisfied: certifi==2022.12.7 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (2022.12.7)\n",
      "Requirement already satisfied: wget in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (3.2)\n",
      "Requirement already satisfied: python-dotenv in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.0.0)\n",
      "Requirement already satisfied: tqdm>=4.41.0 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (4.65.0)\n",
      "Requirement already satisfied: matplotlib in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (3.7.1)\n",
      "Requirement already satisfied: urllib3>=1.26.6 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.26.15)\n",
      "Requirement already satisfied: kiwisolver>=1.3.1 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from roboflow) (1.4.4)\n",
      "Requirement already satisfied: contourpy>=1.0.1 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from matplotlib->roboflow) (1.0.7)\n",
      "Requirement already satisfied: fonttools>=4.22.0 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from matplotlib->roboflow) (4.39.0)\n",
      "Requirement already satisfied: packaging>=20.0 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from matplotlib->roboflow) (23.0)\n",
      "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/dickr/opt/anaconda3/envs/poker310/lib/python3.10/site-packages (from requests->roboflow) (3.1.0)\n",
      "loading Roboflow workspace...\n",
      "loading Roboflow project...\n",
      "Downloading Dataset Version Zip in PlayingCards-1 to yolov7pytorch: 100% [34468644 / 34468644] bytes\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Extracting Dataset Version Zip to PlayingCards-1 in yolov7pytorch:: 100%|██████████| 2032/2032 [00:00<00:00, 6770.38it/s]\n"
     ]
    }
   ],
   "source": [
    "!pip install roboflow\n",
    "\n",
    "from roboflow import Roboflow\n",
    "rf = Roboflow(api_key=\"\")\n",
    "project = rf.workspace(\"poker-v9lfq\").project(\"playingcards-ixvhp\")\n",
    "dataset = project.version(1).download(\"yolov7\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loading Roboflow workspace...\n",
      "loading Roboflow project...\n",
      "{\n",
      "  \"x\": 387,\n",
      "  \"y\": 337,\n",
      "  \"width\": 22,\n",
      "  \"height\": 36,\n",
      "  \"confidence\": 0.5082111358642578,\n",
      "  \"class\": \"KH\",\n",
      "  \"image_path\": \"bet365231.PNG\",\n",
      "  \"prediction_type\": \"ObjectDetectionModel\"\n",
      "}\n",
      "\n",
      "{\n",
      "  \"x\": 556,\n",
      "  \"y\": 558,\n",
      "  \"width\": 24,\n",
      "  \"height\": 33,\n",
      "  \"confidence\": 0.48136740922927856,\n",
      "  \"class\": \"6S\",\n",
      "  \"image_path\": \"bet365231.PNG\",\n",
      "  \"prediction_type\": \"ObjectDetectionModel\"\n",
      "}\n",
      "\n",
      "{\n",
      "  \"x\": 489,\n",
      "  \"y\": 558,\n",
      "  \"width\": 20,\n",
      "  \"height\": 33,\n",
      "  \"confidence\": 0.27771031856536865,\n",
      "  \"class\": \"3D\",\n",
      "  \"image_path\": \"bet365231.PNG\",\n",
      "  \"prediction_type\": \"ObjectDetectionModel\"\n",
      "}\n",
      "\n",
      "{\n",
      "  \"x\": 598,\n",
      "  \"y\": 337,\n",
      "  \"width\": 25,\n",
      "  \"height\": 37,\n",
      "  \"confidence\": 0.2474963665008545,\n",
      "  \"class\": \"10S\",\n",
      "  \"image_path\": \"bet365231.PNG\",\n",
      "  \"prediction_type\": \"ObjectDetectionModel\"\n",
      "}\n",
      "\n",
      "{\n",
      "  \"x\": 489,\n",
      "  \"y\": 558,\n",
      "  \"width\": 20,\n",
      "  \"height\": 33,\n",
      "  \"confidence\": 0.20650482177734375,\n",
      "  \"class\": \"5D\",\n",
      "  \"image_path\": \"bet365231.PNG\",\n",
      "  \"prediction_type\": \"ObjectDetectionModel\"\n",
      "}\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from roboflow import Roboflow\n",
    "rf = Roboflow(api_key=\"\")\n",
    "project = rf.workspace().project(\"playing-cards-ow27d\")\n",
    "model = project.version(4).model\n",
    "\n",
    "# infer on a local image\n",
    "print(model.predict(\"bet365231-1.PNG\", confidence=20, overlap=30))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "print(model.predict(\"Screenshot_14.png\", confidence=20, overlap=30))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "poker310",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
